<template>
	<uv-tabbar :value="current" :fixed="true" @change="onChange">
		<uv-tabbar-item v-for="(item,index) in items" :key="index" :text="item.name" :icon="item.icon" />
	</uv-tabbar>
</template>

<script>
	export default {
		name: "tabbar",
		data() {
			return {
				current: 0 ,
				items: [{
						name: "首页",
						path: "/pages/index",
						icon: "home"
					},
					{
						name: "订单",
						path: "/pages/order",
						icon: "order"
					},
					{
						name: "我的",
						path: "/pages/mine",
						icon: "account"
					},
				]
			};
		},
		created(){
			uni.hideHomeButton()
		},
		mounted() {
			let path =  uni.$uv.page()
			let index = this.items.findIndex(item => {return item.path == path})
			this.current = index
		},
		methods: {
			onChange(index) {
				let path = this.items[index].path
				uni.$uv.route({
					type:"redirect",
					url: path
				});
				this.current = index
			}
		}
	}
</script>

<style lang="scss">

</style>